var dbConfig = require('../util/dbconfig')

//获取头条信息
getHeadLineNews = (req, res) => {
    var sql = "select * from Hnews";
    var sqlArr = [];
    var callBack = (err, conn) => {
        if (err) {
            console.log('连接出错！')
        } else {
            res.send({
                status: 200,
                msg: 'GET请求成功',
                data: conn
            })
        }
    }

    dbConfig.sqlConnect(sql, sqlArr, callBack)
}

//获取法甲新闻
getFrenchArmourNews = (req, res) => {
    var sql = "select * from Fnews";
    var sqlArr = [];
    var callBack = (err, conn) => {
        if (err) {
            console.log('连接出错！')
        } else {
            res.send({
                status: 200,
                msg: 'GET请求成功',
                data: conn
            })
        }
    }

    dbConfig.sqlConnect(sql, sqlArr, callBack)
}

//获取英超新闻
getPremierLeagueNews = (req, res) => {
    var sql = "select * from Pnews";
    var sqlArr = [];
    var callBack = (err, conn) => {
        if (err) {
            console.log('连接出错！')
        } else {
            res.send({
                status: 200,
                msg: 'GET请求成功',
                data: conn
            })
        }
    }

    dbConfig.sqlConnect(sql, sqlArr, callBack)
}

//获取西甲新闻
getLaLigaNews = (req, res) => {
    var sql = "select * from Lnews";
    var sqlArr = [];
    var callBack = (err, conn) => {
        if (err) {
            console.log('连接出错！')
        } else {
            res.send({
                status: 200,
                msg: 'GET请求成功',
                data: conn
            })
        }
    }

    dbConfig.sqlConnect(sql, sqlArr, callBack)
}

//获取意甲新闻
getSerieANews = (req, res) => {
    var sql = "select * from Snews";
    var sqlArr = [];
    var callBack = (err, conn) => {
        if (err) {
            console.log('连接出错！')
        } else {
            res.send({
                status: 200,
                msg: 'GET请求成功',
                data: conn
            })
        }
    }

    dbConfig.sqlConnect(sql, sqlArr, callBack)
}

//获取德甲新闻
getTheBundesligaNews = (req, res) => {
    var sql = "select * from Bnews";
    var sqlArr = [];
    var callBack = (err, conn) => {
        if (err) {
            console.log('连接出错！')
        } else {
            res.send({
                status: 200,
                msg: 'GET请求成功',
                data: conn
            })
        }
    }

    dbConfig.sqlConnect(sql, sqlArr, callBack)
}

module.exports = {
    getHeadLineNews,
    getFrenchArmourNews,
    getPremierLeagueNews,
    getLaLigaNews,
    getSerieANews,
    getTheBundesligaNews
}